The present invention relates to disk cache systems, and more particularly to a method and apparatus for writing cache data to a disk drive and a fast and efficient manner.
It is common to access and retrieve data from an external network using a computer coupled to the external network via any one of many known network connection methods. For example, the computer may be coupled to the internet via an internet server provided (ISP) or the like using a 56 K (56 kilobits per second) analog modem, a digital modem (using ISDN, ADSL, etc.), a cable modem, etc. The computer has an appropriate browser or the like for searching, accessing and retrieving the data from the internet, such as web pages from the world wide web (WWW). The present invention is not limited to the internet, and contemplates any type of external network.
The user often browses the same information during the same communication session or during a later communication session. The external network may experience delays, however, especially during periods of heavy traffic. The communication connection may also be relatively slow. Data caching techniques are often used to temporarily store retrieved data for subsequent access and perusal to avoid the delays associated with the network or the communication connections.
Data is often cached within the dynamic memory of the computer, such as within dynamic random access memory (DRAM) devices or the like commonly used for computer systems. The dynamic memory is a valuable and expensive type of memory, however, and thus is often a limited resource. Data may also be cached to the hard disk drive of the computer system. Such disk drive caching, however, has several disadvantages. Although the disk drive is relatively fast compared to the network, the disk drive is relatively slow compared to the dynamic memory. The disk drive is slow primarily because of the mechanical nature of the drive and the sequential storage of the data on the drive. The data storage and retrieval speed of the disk drive is further reduced by the associated overhead associated with the file structure of the data on the drive. To avoid overwriting any data on the drive, space for a new cache file must be allocated, and the new file must be created to store the data to be cached. When caching data, the read/write (R/W) heads must be moved to access the beginning region of the new cache file. Also, the cache file is often distributed within the disk drive in more than one region, resulting in a substantial write access time as the R/W heads access each of the several regions of the cache file to complete the write operation. Similar delays are encountered when reading cached data from such distributed cache files.
The computer may be coupled to the external network via a local area network (LAN) or the like. The LAN may further include a server computer system and a gateway device, such as a router or the like. The server may be used to cache data for several computers coupled to the LAN in a similar manner as described above for the standalone computer. Caching by the server provides the advantage of allowing any of the computers in the LAN to access cached data. Although the server may be loaded with significantly more dynamic memory, it may still be insufficient to meet the desired caching needs of the LAN. The server may utilize one or more hard disk drives to store cached data in a similar manner as described above. Such disk drive caching techniques, however, have suffered from the same disadvantages described above. It is desired to improve disk drive caching techniques.
A disk drive caching system according to one embodiment of the present invention includes a disk drive, cache write logic and disk drive logic. The cache write logic includes start sector logic that determines a plurality of start sectors including an offset sector relative to a current sector within a current track of the disk drive and at least one other sector that corresponds to the offset sector. The cache write logic further includes select logic that selects one of the plurality of start sectors. The disk drive logic controls read and write caching operations to the disk drive, which includes writing cache data to a write section beginning at a start sector selected by the select logic. In this manner, cache write operations have relatively short write access times.
The disk drive is typically divided into zones, where each zone has a different number of sectors per track. The disk drive caching system may further include an offset table that stores a predetermined sector offset and a predetermined sector step offset for each zone of the disk drive. The predetermined sector offset is associated with a minimal write access time for a corresponding zone and the predetermined sector step offset is associated with sector density of a corresponding zone. The start sector logic retrieves a sector offset and a sector step offset from the offset table for a current zone to determine the offset sector and at least one alternative start sector. In a more particular embodiment, the disk drive includes a plurality of platters and corresponding write surfaces. The start sector logic uses the retrieved sector step offset and the determined offset sector to determine a plurality of aligned sectors in aligned tracks of a current cylinder of the disk drive.
The select logic may further include timing logic that determines a total write time for each of the plurality of start sectors. The disk drive caching system may further include a write time penalty table that includes write time penalties associated with the disk drive. The select logic retrieves and adds any write time penalties from the write time penalty table for each of the plurality of start sectors. The disk drive caching system may select one of the plurality of start sectors that has a least total write time. In another embodiment, the select logic also includes priority logic that determines a priority level of data stored on the disk drive for each of the plurality of start sectors. The select logic determines a write section for each of the plurality of start sectors and the priority logic determines a priority level for each sector of each write section. The select logic assigns a priority level for each write section that is equal to the priority level of a sector having a highest relative priority level within each write section. The select logic may select a start sector associated with the lowest relative priority level. The select logic may select a start sector based on total write time or relative priority or a combination of both.
A data retrieval system for accessing data from an external network according to one embodiment of the present invention includes a local network system that enables retrieval of data from the external network, at least one computer that requests data from the external network via the local network system, and a server system that retrieves and caches data from the external network. The server system further includes a disk drive, a processor, and memory. The server system further includes code, stored in the memory and executed by the processor, for controlling disk cache operations. The code includes start sector code that determines a plurality of potential start sectors, select code that selects a start sector from the plurality of potential start sectors and disk drive code that caches retrieved data onto the disk drive at the selected start sector. The plurality of potential start sectors includes a first start sector having a minimal write access time and at least one other start sector that corresponds with the first start sector that also has a minimal write access time. The start sector code, the select code, and the disk drive code may be part of an operating system that runs on the server system.
The memory may further store a sector offset table, where the start sector code accesses the sector offset table to retrieve a sector offset and a sector step offset to determine the plurality of potential start sectors. The select code may select a start sector to store the retrieved data based on a total write time determined for each of the plurality of potential start sectors. The data retrieval system may further include write delay information stored in the memory, where the select code accesses and uses the write delay information to determine the total write time for each of the plurality of potential start sectors. In another embodiment, the select code selects a start sector based on priority of data currently stored on the disk drive beginning at each of the plurality of potential start sectors. Of course, the select code may select a start sector based on a combination of total write time associated with each write section and priority of data currently stored on the disk drive at each potential start sector.
The local network system may include a gateway device such as a router or the like. The local network system may further include a multiple port network device coupled to the gateway device, such as a hub, repeater, switch or the like. The external network may include or otherwise be coupled to the internet, where the retrieved data includes web page information from the internet, such as the world wide web (WWW).
The disk drive typically includes a plurality of cylinders, each cylinder including a plurality of corresponding tracks. A method of caching data to a disk drive in one embodiment according to the present invention includes determining an offset sector in a current track of the disk drive and determining at least one other sector in a different track of the current cylinder that corresponds to the offset sector. The offset sector and the at least one other sector form a plurality of potential start sectors. The method further includes selecting a start sector from the plurality of start sectors for a cache write operation, and writing cache data to the disk drive beginning with the selected start sector. The determining an offset sector may comprise determining a sector having a minimum write access time after a read operation. The determining an offset sector may alternatively comprise retrieving a sector offset from a table of sector offsets of the disk drive, and adding the retrieved sector offset to a current sector number to obtain an offset sector number. The determining at least one other sector my comprise retrieving one or more sector step offsets from the table of sector offsets, and adding the retrieved sector step offsets to the offset sector number. The determining at least one other sector in a different track of the current cylinder that corresponds to the offset sector may comprise determining aligned sectors in aligned tracks along the current cylinder of the disk drive.
The selecting a start sector may further include determining a total write time associated with each of the plurality of start sectors and selecting a start sector having a least total write time. Alternatively, the selecting a start sector may further include determining a priority level associated with each of the plurality of start sectors and selecting a start sector associated with a lowest priority level. Of course, the selecting a start sector from the plurality of start sectors may comprise using a combination of total write time and relative priority level of each of the plurality of start sectors. The determining a total write time may include adding any write time delays associated with each of the plurality of start sectors. Such write time delays may be determined by consulting a table of predetermined write time delays. The determining a priority level may comprise determining a plurality of write sections corresponding to the plurality of start sectors, determining a priority level of each sector within each of the plurality of write sections, and assigning a priority level to each of the plurality of write sections that is equal to the priority level of an included sector having a highest priority level. A method according to the present invention may further comprise, when the writing cache data to the disk drive, determining a priority level of the cache data to be written and storing a number corresponding to the determined priority level in a file database.
It is now appreciated that a disk cache writing system according to any one or more embodiments according to the present invention substantially improves disk drive caching techniques. A cache disk drive is provided that is dedicated to cache data. Alternatively, a portion of a standard disk drive is reserved for cache data. In this manner, any or all of the current data of the disk drive or cache portion is temporary cache data that may be overwritten at any time. The standard file allocation and storage techniques are avoided thereby substantially reducing write access times. Cache data is written to a write section, including one or more sequential sectors, where the write section has a minimal write access time. The write section begins at a first offset sector associated with a minimal write access time, or at any one of several potential start sectors including the first offset sector. The first start sector resides within the current track of the disk drive to avoid moving the R/W heads to begin the cache write operation. The only initial delay that is encountered is the delay to switch the R/W heads from read to write. On another embodiment, one or more other start sectors, corresponding with the first start sector, are also determined, where each of the other start sectors also avoid moving the R/W heads from the current track since all the R/W heads are aligned within the same current cylinder of the disk drive. The only other delay(s) that may be encountered during the cache write operation are the characteristic delays associated with writing to sequential sectors of the chosen disk drive that are otherwise unavoidable, such as delays associated with switching sequential tracks, heads, surfaces, platters, etc.